<?php echo form_open('transaction/search/',array('method' => 'get')); ?>

<div class="header1">Search Options</div>
<div id="options">
	<ul style="display: inline;">
		<li><input type="radio" name="search_type" id="transaction" value="0"
		<?php if($search_type == '0')echo 'checked';?> /> transaction's id</li>
		<li><input type="radio" name="search_type" id="barcode" value="1"
		<?php if($search_type == '1')echo 'checked';?> /> item barcode</li>
		<li><input type="text" name="search" class="textboxSearch"
			value="<?php echo $search; ?>" placeholder="please enter the keyword"
			maxlength="30" /> <input type="submit" id="btn_submit"
			class="buttonSearch" value="search">
		</li>
	</ul>
</div>

<?php echo form_close(); ?>
<div class="titleStyle1">Transaction Details</div>
<?php 
if ($search_type == 0) {

	if ($result == null || sizeof($result) == 0){
		echo '<div class="information">';
		echo 'no transaction found.';
		echo '</div>';
	}else{
		echo '<div class="waitingTable">';
		echo '<table>';
		echo '<tr>';
		echo '<td>';
		echo 'Transaction ID';
		echo '</td>';
		echo '<td>';
		echo 'Cashier ID';
		echo '</td>';
		echo '<td>';
		echo 'Item\'s Name';
		echo '</td>';
		echo '<td>';
		echo 'Item Barcode';
		echo '</td>';
		echo '<td>';
		echo 'Quantity';
		echo '</td>';
		echo '<td>';
		echo 'Total Price';
		echo '</td>';
		echo '<td>';
		echo 'Transaction Date';
		echo '</td>';
		echo '</tr>';
		foreach ($result as $trans){
			echo '<tr>';
			echo '<td>';
			echo $trans->transaction_id;
			echo '</td>';
			echo '<td>';
			echo $trans->cashier_id;
			echo '</td>';
			echo '<td>';
			echo $trans->item_name;
			echo '</td>';
			echo '<td>';
			echo $trans->item_barcode;
			echo '</td>';
			echo '<td>';
			echo $trans->transaction_quantity;
			echo '</td>';
			echo '<td>';
			echo $trans->total_price;
			echo '</td>';
			echo '<td>';
			echo $trans->transaction_date;
			echo '</td>';
			echo '</tr>';
		}
		echo '</table>';
		echo '</div>';
		echo $links;
	}
}else{
	if ($result == null || sizeof($result) == 0){
		echo '<div class="information">';
		echo 'no transaction found.';
		echo '</div>';
	}else{
		echo '<div class="waitingTable">';
		echo '<table>';
		echo '<tr>';
		echo '<td>';
		echo 'Item\'s Name';
		echo '</td>';
		echo '<td>';
		echo 'Item Barcode';
		echo '</td>';
		echo '<td>';
		echo 'Quantity Sold';
		echo '</td>';
		echo '<td>';
		echo 'Profit';
		echo '</td>';
		echo '</tr>';
		foreach ($result as $trans){
			echo '<tr>';
			echo '<td>';
			echo $trans->item_name;
			echo '</td>';
			echo '<td>';
			echo $trans->item_barcode;
			echo '</td>';
			echo '<td>';
			echo $trans->quantity;
			echo '</td>';
			echo '<td>';
			echo $trans->sum;
			echo '</td>';
			echo '</tr>';
		}
		echo '</table>';
		echo '</div>';
		echo $links;
	}
}
?>
